package net.osc.web;

import java.io.PrintWriter;
import java.io.StringWriter;

/**
 * 
 * @author <a href=mailto:peng.wu@foxmail.com>wu.peng</a> 2012-8-14
 *
 */
public class JsonResult {
	
	private Boolean success = true;
	private String msg = "";
	private Object relate;
	private String stackTrace = "";
	
	public JsonResult() {
	}
	
	public JsonResult(Boolean success,String msg) {
		this.success = success;
		this.msg = msg;
	}
	
	public JsonResult(Boolean success,String msg,Object relate) {
		this.success = success;
		this.msg = msg;
		this.relate = relate;
	}
	
	public JsonResult(Exception ex) {
		this.success = false;
		this.msg = ex.getMessage();
		StringWriter sw = new StringWriter();
		PrintWriter pw = new PrintWriter(sw);
		ex.printStackTrace(pw);
		pw.flush();
		pw.close();
		this.stackTrace = sw.toString();
	}
	
	public Boolean getSuccess() {
		return success;
	}

	public void setSuccess(Boolean success) {
		this.success = success;
	}

	public String getMsg() {
		return msg;
	}

	public void setMsg(String msg) {
		this.msg = msg;
	}

	public Object getRelate() {
		return relate;
	}

	public void setRelate(Object relate) {
		this.relate = relate;
	}

	public String getStackTrace() {
		return stackTrace;
	}

	public void setStackTrace(String stackTrace) {
		this.stackTrace = stackTrace;
	}
	
	
	
	

}
